<!DOCTYPE html>
<html>
<head>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
    <meta charset="UTF-8">
    <link href="/css/vendor/common.css" rel="stylesheet" type="text/css">
    <link href="/css/vendor/cmp-controls.css" type="text/css" rel="stylesheet">
    <link href="/css/vendor/firmware-download.less" rel="stylesheet/less" type="text/css">
    <script src="/js/less.min.js"></script>
    <title>飞马测试固件下载中心</title>
</head>

<body>
<main>
    <header>
        <div class="center-wrap">
            <div class="logo-1 center-v"><a href="/firmware/firmwareDownloadList"></a></div>
            <div class="logo-2"></div>
        </div>
    </header>
    <div class="center-list">
        <p>飞马测试固件下载中心</p>

    </div>
</main>
</body>
<script src="/js/jquery-3.2.1.min.js"></script>
<script src="/js/vendor/common.js"></script>
<script src="/js/vendor/cmp-controls.js"></script>
<script>
    $(function () {
        init();
    });
    function bindTable() {
        $(".type-title-wrap").on("click", function() {
            $(this).siblings().fadeToggle("slow");
            $(this).children(".type-toggle").toggleClass("rotate");
        });
    };

    function init() {
        feimaPost("/firmware/getFirmwareList", "", function (result) {
            if(result.status == 0){
                console.log(result.data);
                addTable(result.data);
                bindTable();
            }else{
                FAlert(result.message);
            }
        });
    }

    function addTable(data) {
        var addList = "";
        for (var index in data){
            var addTable = "<div class='type-list'><div class='type-title-wrap'><div class='type-toggle'></div><span>";
            addTable += data[index]["name"];
            addTable += "</span></div><table>";
            var infoData = data[index]["info"];
            for (var _index in infoData){
                addTable += "<tr>";
                addTable += "<td class='date'>" + infoData[_index]["created_at"] + "</td>";
                addTable += "<td class='version'>" + infoData[_index]["version"].substr(0, 15) + "</td>";
                addTable += "<td class='name'>" + infoData[_index]["name"].substr(0, 50) + "</td>";
                addTable += "<td class='content'><a onclick='detailPage(" + infoData[_index]["id"] + ")'>详情</a></td>";
                addTable += "<td class='link'><a href='" + infoData[_index]["url"] + "'>下载</a></td>";
                addTable += "</tr>";
            }
            addTable += "</table></div>";
            addList += addTable;
        }
        $(".center-list").append(addList);
    }

    function detailPage(id) {
        window.open("/firmware/firmwareDetail?id=" + id);
    }


</script>
</html>